Passed
Pull Request — master (#160)
by
unknown
02:21 queued 40s
created

ID3Util.ts ➔ encodingFromStringOrByte   A

Complexity

Conditions 3

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 16
rs 9.75
c 0
b 0
f 0
cc 3
1
import { FrameOptions, FRAME_OPTIONS } from './definitions/FrameOptions'
2
import { isKeyOf } from './util'
3
4
export function getFrameOptions(frameIdentifier: string): FrameOptions {
5
    if (isKeyOf(frameIdentifier, FRAME_OPTIONS)) {
6
        return FRAME_OPTIONS[frameIdentifier]
7
    }
8
    return {
9
        multiple: false
10
    }
11
}
12
13
export function processUnsynchronisedBuffer(buffer: Buffer) {
14
    const newDataArr = []
15
    if (buffer.length > 0) {
16
        newDataArr.push(buffer[0])
17
    }
18
    for(let i = 1; i < buffer.length; i++) {
19
        if (buffer[i - 1] === 0xFF && buffer[i] === 0x00) {
20
            continue
21
        }
22
        newDataArr.push(buffer[i])
23
    }
24
    return Buffer.from(newDataArr)
25
}
26